
-- usage:    v_int_type_variable   = get_cfg_int_f( property_name );
--           v_vchar_type_variable = get_cfg_vchar_f( property_name );
--           v_date_type_variable  = get_cfg_date_f( property_name );



-- property name as argument
CREATE OR REPLACE FUNCTION get_cfg_int_f(varchar) RETURNS integer AS $$
BEGIN
  IF    ($1 = 'fiscal_month_start_p') THEN RETURN 10;
  ELSIF ($1 = 'fiscal_month_end_p')   THEN RETURN 9;
  ELSE  RAISE EXCEPTION 'Looks like new config property; please add';
  END IF;
END;
$$ LANGUAGE plpgsql;

-- property name as argument
CREATE OR REPLACE FUNCTION get_cfg_vchar_f(varchar) RETURNS varchar AS $$
BEGIN
  IF    ($1 = 'someprop1_p') THEN RETURN 'testing1';
  ELSIF ($1 = 'someprop2_p') THEN RETURN 'testing2';
  ELSE  RAISE EXCEPTION 'Looks like new config property; please add';
  END IF;
END;
$$ LANGUAGE plpgsql;

-- property name as argument
CREATE OR REPLACE FUNCTION get_cfg_date_f(varchar) RETURNS date AS $$
BEGIN
  IF    ($1 = 'someprop1_p') THEN RETURN '06/07/2007';
  ELSIF ($1 = 'someprop2_p') THEN RETURN CURRENT_DATE;
  ELSE  RAISE EXCEPTION 'Looks like new config property; please add';
  END IF;
END;
$$ LANGUAGE plpgsql;
